#ifndef GEOCOORD_H_
#define GEOCOORD_H_

#include "../Math/Math.h"

namespace uav
{
namespace nav
{

using namespace math;

// Constants used for geodetic/ECEF conversions
const Fixed WGS84_A          = Fixed(6378137.0); ///< WGS 84 constant semi-major axis
const Fixed WGS84_E2         = Fixed(0.00669437999014); ///< WGS 84 constant first eccentricity squared
const Fixed WGS84_1_MINUS_E2 = Fixed(0.99330562000986); ///< WGS 84 constant one minus first eccentricity squared

class RefFrame;

/**
 * @class GeoCoord
 * @brief Geodetic coordinates (latitude, longitude, altitude) class.
 */
class GeoCoord
{
public:
	Fixed latitude; ///< The latitude in radians.
	Fixed longitude; ///< The longitude in radians.
	Fixed altitude; ///< The altitude above MSL in meters.

	GeoCoord() {}

	/**
	 * Constructs a geodetic coordinate with the specified latitude, longitude, and altitude.
	 */
	GeoCoord(Fixed lat, Fixed lon, Fixed alt) : latitude(lat), longitude(lon), altitude(alt) {}

	/**
	 * Converts the geodetic coordinates to ECEF coordinates.
	 */
	Vector3 toEcef() const;

	/**
	 * Converts the geodetic coordinates to ENU coordinates in the provided ENU reference frame.
	 */
	Vector3 toEnu(const RefFrame &ref) const;
};

}}

#endif
